public class eString_builder {
    class Solution {
        public String tree2str(TreeNode root) {
            stringbuilder stringbuilder = new stringbuilder();
            strmethod(root,stringbuilder);
        }
        public String strmethod(TreeNode root,stringbuilder stringbuilder){
            stringbuilder.append(root.val);
            if(root.left != null){
                stringbuilder.append("(");
                strmethod(root.left,stringbuilder);
                stringbuilder.append(")");
            }
            else{
                if(root.right == null){
                    return;
                }else{
                    stringbuilder.append("()");
                }
                if(t.right != null){
                    stringbuilder.append("(");
                    strmethodroot(root.right,stringbuilder);
                    stringbuilder.append(")");
                }
                else{
                    return;
                }
            }
        }
    }
}
